package com.viettel.synctask;

import java.util.ArrayList;

import android.os.AsyncTask;
import android.util.Log;

import com.viettel.BO.CandidateBean;
import com.viettel.BO.PortalUserBean;
import com.viettel.data.LoginFetcher;
import com.viettel.rmsmobile.CandidateCareerFragment;
import com.viettel.rmsmobile.MainActivity;
import com.viettel.rmsmobile.UserLoginActivity;

public class LoginSyncTask extends AsyncTask<Object, Boolean, PortalUserBean> {

	UserLoginActivity loginActivity;

	@Override
	protected PortalUserBean doInBackground(Object... params) {
		loginActivity = (UserLoginActivity) params[0];
		String email = (String) params[1];
		String password = (String) params[2];
		LoginFetcher loginFetcher = new LoginFetcher(email, password);
		PortalUserBean portalUserBean = loginFetcher.getPortalUser();
		return portalUserBean;
	}


	@Override
	protected void onPostExecute(PortalUserBean response) {
		try {
			MainActivity.portalUser = response;
			MainActivity.portalUserId = response.getPortalUserId();
			loginActivity.viewUserInfo();
		} catch (Exception e) {
			Log.d("Error: ", " " + e.getMessage());
		}
		super.onPostExecute(response);
	}
}
